<?php
if (!defined('BASEPATH'))
    exit('No direct script access allowed');
//require_once('MY_FPDF.php');
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class DaftarSiswaPerkelas extends MY_FPDF {

    function Header() {
       
//Logo
        $this->Image($this->logourl, 3, 3, 15);

//Arial bold 15
        $this->SetFont('Arial', 'B', 12);
        $this->SetTextColor(1, 50, 155);
        $this->SetY(8);
        $this->Cell(13);
        $this->Cell(70, 5, $this->namasekolah, 0);
        $this->Cell(117, 5, '',0);
        $this->Ln(5);
        $this->SetFont('Arial', 'B', 8);
        $this->Cell(13);
        $this->Cell(70, 3, $this->alamat,0);        
        
        
        $this->SetFont('Arial', 'I', 8);
        $this->SetY(8);
        $this->Cell(157);
        $this->Cell(20, 3, 'Tanggal Cetak', 0, 0, 'L');
        $this->Cell(3, 3, ':', 0, 0, 'C');
        $this->Cell(20, 3, date('d/m/Y'), 0, 0, 'R');
        $this->Ln(3);
        $this->Cell(157);
        $this->Cell(20, 3, 'Waktu Cetak', 0, 0, 'L');
        $this->Cell(3, 3, ':', 0, 0, 'C');
        $this->Cell(20, 3, date('h:i:s'), 0, 0, 'R');
        $this->Ln(3);
        $this->Cell(157);
        $this->Cell(20, 3, 'Halaman', 0, 0, 'L');
        $this->Cell(3, 3, ':', 0, 0, 'C');
        $this->Cell(20,3, $this->PageNo() . ' dari {nb}', 0, 0, 'R');
//        $this->Ln();
        $this->SetDrawColor(1, 50, 155);
        $this->SetLineWidth(.25);
        $this->Line(5, 19, 205, 19);
        
        $this->Ln(6);
        
        $this->SetTextColor(0, 0, 0);
        $this->SetX(5);
        $this->SetFont('Arial', 'B', 10);
        $this->Cell(0, 5, 'DAFTAR SISWA', 0, 0, 'C');
        $this->Ln();
        $this->SetX(5);
        $this->SetFont('Arial', '', 10);
        if(count($this->dataheader)>0){
            $this->Cell(0, 5, 'TAHUN AJARAN '.$this->dataheader->tahun_ajaran.' / SEMESTER '.$this->dataheader->semester, 0, 0, 'C');        
        }else{
            $this->Cell(0, 5, '', 0, 0, 'C');        
        }
        
        $this->Ln(10);
    }
     public function set_header_column($w) {
        $head = array('No', 'Nis', 'Nama Siswa', 'TH.Masuk', 'TH.Alumni', 'Alamat','Telepon','Seluler');
        $alignhead=array('C', 'C', 'C', 'C', 'C', 'C','C','C');
        $borderhead=array('TBL', 'TBL', 'TBL', 'TBL', 'TBL', 'TBL','TBL',1);
        $this->SetFont('Arial', 'B', 8);
        $this->SetX(5);
        for($i=0;$i<count($w);$i++){
            $this->Cell($w[$i], 4, $head[$i], $borderhead[$i], 0,$alignhead[$i]);
        }
        $this->Ln();
    } 
    public function create_pdf($data){
        $this->AddPage();
        $this->SetAutoPageBreak(true,18);
        $w=array(10, 20, 40, 16, 16, 52,23,23);
        $al=array('R','C', 'L', 'C','C','L','L','L');
        $this->SetWidths($w);
        $this->SetAligns($al);
        $this->lineh=4;
        $this->set_header_column($w);
        $kelas='';
        $number=0;
        foreach ($data as $v) {
            if($v->kd_kelas !== $kelas)
            {
//                if($kelas !== ''){
                    $this->Ln();
//                }
                $number=0;
                $kelas=$v->kd_kelas;
                $this->CheckPageBreak($this->lineh+8);
//                $this->lineh=$h;
                $this->SetFont('Arial', 'BI', 8);
                $this->SetX(5);
                $this->Cell(200, $this->lineh, $v->kelas, 0, 0, 'L', false);
                $this->Ln();
            }
            $number++;
            $this->SetFont('Arial', '', 8);
            $this->RowHead(
                        array(
                            $number,
                            $v->nis,
                            $v->nama,
                            $v->th_masuk,
                            $v->th_alumni,
                            $v->alamat,
                            $v->telepon,
                            $v->seluler
                            
                        ),
                        $w,
                        $al,   
                        $this->lineh,1,1
                    );
        }
    }
}
?>
